Skip to content

fix(ai): align Anthropic and OpenAI message conversion - #1949

Merged
wsp1911 merged 1 commit into
GCWing:mainfrom
wsp1911:dev
Aug 1, 2026
Merged

fix(ai): align Anthropic and OpenAI message conversion#1949
wsp1911 merged 1 commit into
GCWing:mainfrom
wsp1911:dev

Conversation

@wsp1911

@wsp1911 wsp1911 commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Normalize Anthropic user and assistant turns as content blocks, then merge consecutive compatible turns without flattening their blocks.
  • Preserve explicit empty assistant content for OpenAI tool-call replay, while omitting the field only when it is absent.
  • Stop sending name on OpenAI tool messages.

Type and Areas

Type:

Bug fix

Areas:

AI adapters

Motivation / Impact

Keeps provider replay payloads faithful to their source message shape: Anthropic consecutive turns retain block boundaries, and OpenAI-compatible tool-call turns no longer rewrite "" as whitespace or attach a tool-message name.

Verification

  • pnpm run fmt:rs
  • cargo test -p bitfun-ai-adapters message_converter — 26 passed
  • git diff --cached --check
  • cargo check --workspace

Reviewer Notes

  • The existing OpenAI Chat Completions tool-image behavior is intentionally unchanged in this PR.
  • Scope is limited to the two provider message converters.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, including the incomplete workspace check.
  • No user-facing strings, docs, or locales were changed.

- normalize Anthropic turns as content blocks before merging
- preserve empty OpenAI assistant tool-call content and omit only absent content
- avoid emitting unsupported names on OpenAI tool messages
@wsp1911
wsp1911 marked this pull request as ready for review August 1, 2026 08:56
@wsp1911
wsp1911 merged commit 837671f into GCWing:main Aug 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant